// 如何存储effect
// dep存储effect, trigger触发响应式

// store effect
let dep = new Set();
function track() {
  dep.add(effect);
}
function trigger() {
  dep.forEach((effect) => effect());
}

let price = 5;
let quantity = 2;
let total = 0;
let effect = () => {
  total = price * quantity;
};
track(); // save this code
effect(); // run this effect
console.log(total); // 10

price = 10;
quantity = 4;
trigger(); // run all the code I've saved
console.log(total); // 40
